<template>
  <div>
    <FormPanel ref="from" :list="formList" @formChange="changeHandle" :isSubmitBtn="false" :collapse="false" labelWidth="110" />


    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <el-button @click="closeDrawer(1)">关 闭</el-button>
      <!-- <el-button @click="closeDrawer(2)" type="primary">确 认</el-button> -->
      <multiuse-button type="primary" :click="closeDrawer.bind(this, 2)">确 认</multiuse-button>
    </div>
  </div>
</template>
<script>
import {confirmLock} from '@/api/omSale/HeadquartersInventory/HeadquartersResources'
export default {
  data(){
    return{
      formList:this.createdFrom(),
    }
  },
  components:{
  },
  props:['list'],
  methods:{
    createdFrom(){
      return [


        {
          type: 'TEXT_AREA',
          label: '锁定原因',
          fieldName: 'lockRemark',
          placeholder: '请输入',
          selfCols:3,
          rules: [{ required: true, message: '请输入', trigger: 'blur' }],
        },
      ]
    },

    changeHandle(val){
      this.saveData=val;
    },
    async closeDrawer(type){
      if(type==1){
        this.$emit('close')
      }else if(type==2){
        this.$refs.from.SUBMIT_FORM();
        console.log(this.saveData, 'this.saveData');
        if (this.saveData) {
          let json = JSON.parse(JSON.stringify(this.saveData));
          let arr=[]
          this.list.map(x=>{
            arr.push(`${x.id}`)
          })
          json.ids=arr;
          json.lockStatus=10041001
          let res = await confirmLock(json);
          if (res.resultCode == 200) {
            this.$notify({
              title: '成功',
              message: '锁定成功',
              type: 'success'
            });
            this.$emit('close', json);
          }else{
            this.saveData=null;
          }
        }

      }
    }
  }
}
</script>
